package scrum.server.project;

import ilarkesto.fp.Predicate;

public class ProjectGroupDao extends GProjectGroupDao {

	public ProjectGroup getProjectGroupByNumber(final int number, final Project project) {
		return getEntity(new Predicate<ProjectGroup>() {

			@Override
			public boolean test(ProjectGroup pg) {
				return pg.isNumber(number) && pg.isProject(project);
			}
		});
	}

	@Override
	public ProjectGroup newEntityInstance() {
		ProjectGroup projectGroup = super.newEntityInstance();
		projectGroup.setLabel("New Project Group");
		return projectGroup;
	}

	// --- test data ---

	public ProjectGroup postProjectGroup(Project project, String label) {
		ProjectGroup projectGroup = newEntityInstance();
		projectGroup.setProject(project);
		projectGroup.setLabel(label);
		saveEntity(projectGroup);
		return projectGroup;
	}
}